"""
__author__ = '霍格沃兹测试开发学社'
__desc__ = '更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860'
"""
from appium.webdriver.common.appiumby import AppiumBy

from base.base_page import BasePage


class ProductPage(BasePage):
    _BTN_BUY = (AppiumBy.XPATH, "//*[@text='立即购买']")
    _STOCK_NUM = (AppiumBy.ID, "com.ceshiren.litemall:id/number")
    def buy_now(self):
        # 点击【立即购买】
        self.find_and_click(*self._BTN_BUY)
        from page.litemall_pages.main_page import MainPage
        return MainPage(self.driver)

    def get_stock_num(self):
        num = self.find_and_gettext(self._STOCK_NUM)
        return num